{extend name="platform/base" /}
{block name="resources"/}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<style>
/* .adduserinfo{
	background: #65bd77;
    border: 0;
    color: #fff;
    line-height: 30px;
} */
.table>tbody#list>tr>td>img{max-height:60px;}
</style>

{/block}

 {block name="main"}
<div class="row padder-v">
	<div class="col-sm-9" style="width:74%;">
<!-- 	<input type="button" value="添加会员" onclick="add_user();" class="adduserinfo"/> -->
	<a href="javascript:;" class="btn btn-sm btn-primary" onclick="add_user();"><i class="fa fa-plus"></i> 添加会员 </a></div>
	<div class="col-sm-2">
		<div class="input-group">
			<input type="text" class="input-sm form-control" id="search_text"
				placeholder="请输入用户名">
		</div>
	</div>
	<div class="col-sm-1">
		<div class="input-group">
			<span class="input-group-btn">
				<button class="btn btn-sm btn-default" type="button"
					onclick="LoadingInfo(1)">搜索</button>
			</span>
		</div>
	</div>
</div>
<section class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-striped b-t b-light text-sm">
			<thead>
				<tr>
					<th width="20"><input type="checkbox"></th>
					<th>会员</th>
					<th class="center">会员等级</th>
					<th class="center">积分</th>
					<th class="center">账户余额</th>
					<th class="center">注册&登录</th>
					<th class="center">状态</th>
					<th class="center">操作</th>
				</tr>
			</thead>
			<tbody id="list">
				<tr></tr>
			</tbody>
		</table>
	</div>
	{include file="platform/page" /}
</section>

<!-- 充值购物币（Modal）开始 -->
<div class="modal fade" id="rechargeCoin">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">充值购物币</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal">
					<div class="form-group">
						<div class="col-sm-12">
							<label
								style="float: left; margin-right: 20px; line-height: 35px;">购物币个数:</label>
							<input type="text" class="form-control" id="num"
								placeholder="请输入充值购物币个数"
								style="width: 200px; float: left; margin-right: 10px;">
							<span class="help-block m-b-none" style="line-height: 35px;">个</span>
						</div>

					</div>
					<div>
						<lable
							style="float: left;margin-right: 20px;line-height: 35px;font-weight: 600;">备注：</lable>
						<textarea id="text" type="text"
							style="width: 300px; height: 80px; border-color: #d9d9d9; border-radius: 2px;"></textarea>
						<input type="hidden" id="uid" value="" />
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-info"
					onclick="addRechargeCoin()">保存</button>
			</div>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal -->
</div>
<!-- 充值购物币（Modal）结束 -->
<!-- 余额调整 -->
<div class="modal" id="recharge_balance" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">调整余额</h4>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style">
					<table>
						<tr>
							<td>当前余额</td>
							<td colspan='3' id="current_balance"></td>
						</tr>
						<tr>
							<td>调整金额</td>
							<td colspan='3' id="time"><input type="number" id="balance" class="balance" />增加或减少</td>
						</tr>
						<tr>
							<td>备注</td>
							<td colspan='3' id="time"><textarea id="remark_balance"></textarea></td>
						</tr>
					</table>
				</div>
			</div>
			
			<div class="modal-footer">
				<input type="hidden" id="balance_id" />
				<button class="btn btn-info" onclick="addAccount(2)" id="butSubmit" data-dismiss="modal" aria-hidden="true" style="display:inline-block;">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
	
</div>

<!-- 积分调整 -->
<div class="modal" id="recharge_point" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">调整积分</h4>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style">
					<table>
						<tr>
							<td>当前积分</td>
							<td colspan='3' id="current_point"></td>
						</tr>
						<tr>
							<td>调整积分</td>
							<td colspan='3' id="time"><input type="number" id="point" class="point">增加或减少</td>
						</tr>
						<tr>
							<td>备注</td>
							<td colspan='3' id="time"><textarea id="remark_point"></textarea></td>
						</tr>
					</table>
					
				</div>
			</div>
			<div class="modal-footer">
				<input type="hidden" id="point_id" />
				<button class="btn btn-info" onclick="addAccount(1)" id="butSubmit" data-dismiss="modal" aria-hidden="true" style="display:inline-block;">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
	
</div>
<!-- 添加会员 -->
<div class="modal" id="add_user" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">添加会员</h4>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style" style="height:370px;overflow:auto;">
					<table class="modal-tab">
						<tr>
							<td style="width:20%;"><span class="required">*</span>用户名</td>
							<td colspan='3'>
								<input type="text" id="username"/>
								<span id="usernameyz"></span>
								<input type="hidden" value="不存在" id="isset_username"/>
							</td>
						</tr>
						<tr>
							<td><span class="required">*</span>登录密码</td>
							<td colspan='3'><input type="password" id="password" class="balance"></td>
						</tr>
						<tr>
							<td style="width:22%;">昵称</td>
							<td colspan='3'>
								<input type="text" id="nickname"/>
							</td>
						</tr>
						<tr>
							<td>会员等级</td>
							<td colspan='3'>
								<p>
									{if $level_list['data']}
									<select id="member_level">
										{foreach name="level_list['data']" item="vo"}
										<option value="{$vo.level_id}">{$vo.level_name}</option>
										{/foreach}
									</select>
									{else/}
									<span>暂无会员等级分类</span>
									{/if}
								</p>
							</td>
						</tr>
						<tr>
							<td>手机号码</td>
							<td colspan='3'><input type="text" id="telephone"/></td>
						</tr>
						<tr>
							<td>邮箱地址</td>
							<td colspan='3'><input type="text" id="member_email"/></td>
						</tr>
						<tr>
							<td>性别</td>
							<td><label><input type="radio" checked="checked" name="sex" value="1"/>男&nbsp;&nbsp;</label><label><input name="sex" type="radio" value="2"/>女&nbsp;&nbsp;</label><label><input name="sex" type="radio" value="0"/>保密</label></td>
						</tr>
						<tr>
							<td>账户状态</td>
							<td><label><input type="radio" checked="checked" name="status" value="1"/>正常&nbsp;&nbsp;</label><label><input name="status" type="radio" value="0"/>锁定</label></td>
						</tr>
					</table>
				</div>
			</div>
			
			<div class="modal-footer">
				<button class="btn btn-info" onclick="addUser()" id="butSubmit"  style="display:inline-block;">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
	
</div>
<input type="hidden" id="modify_uid"/>

<!-- 修改会员 -->
<div class="modal" id="modify_user" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">编辑会员</h4>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style" style="height:260px;overflow:auto;">
					<table class="modal-tab">
						<tr>
							<td style="width:20%"><span class="required">*</span>用户名</td>
							<td colspan='3'>
								<span id="modify_username"></span>
								<span id="modify_usernameyz"></span>
								<input type="hidden" value="不存在" id="modify_isset_username"/>
							</td>
						</tr>
						<tr>
							<td style="width:20%">昵称</td>
							<td colspan='3'><input type="text" id="modify_nickname"/></td>
						</tr>
						<tr>
							<td>会员等级</td>
							<td colspan='3'>
								<p>
									{if $level_list['data']}
									<select id="modify_member_level">
										{foreach name="level_list['data']" item="vo"}
										<option value="{$vo.level_id}">{$vo.level_name}</option>
										{/foreach}
									</select>
									{else/}
									<span>暂无会员等级分类</span>
									{/if}
								</p>
							</td>
						</tr>
						<tr>
							<td>手机号码</td>
							<td colspan='3'><input type="text" id="modify_telephone" value=""/></td>
						</tr>
						<tr>
							<td>邮箱地址</td>
							<td colspan='3'><input type="text" id="modify_member_email"/></td>
						</tr>
						<tr>
							<td>性别</td>
							<td id="sex"><label><input type="radio" name="sex" value="1"/>男&nbsp;&nbsp;</label><label><input name="sex" type="radio" value="2"/>女&nbsp;&nbsp;</label><label><input name="sex" type="radio" value="0"/>保密</label></td>
						</tr>
						<tr>
							<td>账户状态</td>
							<td id="status"><label><input type="radio" name="status" value="1"/>正常&nbsp;&nbsp;</label><label><input name="status" type="radio" value="0"/>锁定</label></td>
						</tr>
					</table>
				</div>
			</div>
			
			<div class="modal-footer">
				<input type="hidden" id="modify_username_hidden" />
				<button class="btn btn-info" onclick="modifyUser()" id="butSubmit"  style="display:inline-block;">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
	
</div>
<!-- 修改会员 -->
<div class="modal" id="modify_password" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">重置密码</h4>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style">
					<table class="modal-tab">
						<tr>
							<td style="width:20%">密码</td>
							<td colspan='3'><input type="text" id="modify_passwords"/></td>
						</tr>
					</table>
				</div>
			</div>
			
			<div class="modal-footer">
				<input type="hidden" id="modify_userid" />
				<button class="btn btn-info" onclick="modifypassword()" id="butSubmit"  style="display:inline-block;">保存</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
	
</div>


{/block} {block name="script"}
<script type="text/javascript">

$(function(){
	LoadingInfo(1);
})
	function LoadingInfo(pageIndex) {
		var search_text = $("#search_text").val();
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/member/memberlist')}",
			async : true,
			data : {
				"pageIndex" : pageIndex, "search_text" : search_text
			},
			success : function(data) {
// 				alert(JSON.stringify(data));
				var html = '';
				$("#total_count_num").text(data["total_count"]);
				$("#page_count_num").text(data["page_count"]);
				$("#page_count").val(data["page_count"]);
				$("#pageNumber a").remove();
				if (data["data"].length > 0) {
					for (var i = 0; i < data["data"].length; i++) {
						html += '<tr align="center">';
						html += '<td><div class="cell"><label ><input name="sub" type="checkbox" value="'+ data["data"][i]["uid"]+'" ></label></div></td>';
						html += '<td align="left">';
							
						if(data["data"][i]["user_headimg"] ==""){
							html += '<img src="__STATIC__/images/default_user_portrait.gif" class="head-portrait" />';
							if(data["data"][i]["user_name"] == '' || data["data"][i]["user_name"] == null){
								html+='用户名:'+'--'+'<br/>';
							}else{
								html+='用户名:'+data["data"][i]["user_name"] +'<br/>';
							}
							if (data["data"][i]["user_tel"] == null || "" == data["data"][i]["user_tel"]) {
								if (data["data"][i]["user_email"] == null || "" == data["data"][i]["user_email"]) {
									html += '昵称 : '+data["data"][i]["nick_name"] +'<br/>'+'手机 : '+'--'+'<br/>'+'邮箱 : '+'--';
								} else {
									html += '昵称 : '+data["data"][i]["nick_name"] +'<br/>'+'手机 : '+'--'+'<br/>'+'邮箱 : '+data["data"][i]["user_email"];
								}
							} else {
								if (data["data"][i]["user_email"] == null || "" == data["data"][i]["user_email"]) {
									html += '昵称 : '+data["data"][i]["nick_name"] +'<br/>'+'手机 : '+data["data"][i]["user_tel"]+'<br/>'+'邮箱 : '+'--';
								} else {
									html += '昵称 : '+data["data"][i]["nick_name"] +'<br/>'+'手机 : '+data["data"][i]["user_tel"]+'<br/>'+'邮箱 : '+data["data"][i]["user_email"];
								}
							}
						}else{
							html += '<img src="__UPLOAD__/'+data["data"][i]["user_headimg"]+'" class="head-portrait" />';
							if (data["data"][i]["user_tel"] == null || "" == data["data"][i]["user_tel"]) {
								if (data["data"][i]["user_email"] == null || "" == data["data"][i]["user_email"]) {
									html += '昵称 : '+data["data"][i]["nick_name"] +'<br/>'+'手机 : '+'--'+'<br/>'+'邮箱 : '+'--';
								} else {
									html += '昵称 : '+data["data"][i]["nick_name"] +'<br/>'+'手机 : '+'--'+'<br/>'+'邮箱 : '+data["data"][i]["user_email"];
								}
							} else {
								if (data["data"][i]["user_email"] == null || "" == data["data"][i]["user_email"]) {
									html += '昵称 : '+data["data"][i]["nick_name"] +'<br/>'+'手机 : '+data["data"][i]["user_tel"]+'<br/>'+'邮箱 : '+'--';
								} else {
									html += '昵称 : '+data["data"][i]["nick_name"] +'<br/>'+'手机 : '+data["data"][i]["user_tel"]+'<br/>'+'邮箱 : '+data["data"][i]["user_email"];
								}
							}
						}
						html += '</td>';
						if(data["data"][i]["level_name"]==null || data["data"][i]["level_name"]==undefined){
							html += '<td class="tal">--</td>';
						}else{
							html += '<td class="tal">' + data["data"][i]["level_name"] + '</td>';
						}
						html += '<td class="tal">' + data["data"][i]["point"] + '</td>';
						html += '<td class="tal">'+'¥'+ data["data"][i]["balance"] +'</td>';
						html += '<td class="tal">' +'注册时间 : '+ timeStampTurnTime(data["data"][i]["reg_time"]) +'<br>'+'最后登录 : '+ timeStampTurnTime(data["data"][i]["current_login_time"])+'</td>';
						html += data["data"][i]["user_status"] == 0 ? '<td style="color:red;">锁定</td>' : '<td style="color:green;">正常</td>';
						html += '<td><a href="'+ __URL('PLATFORM_MAIN/member/pointdetail?member_id='+ data['data'][i]['uid']) +'">积分明细</a>&nbsp;&nbsp;';
						html += '<a href="' +  __URL('PLATFORM_MAIN/member/accountdetail?member_id='+ data['data'][i]['uid']) +'">余额明细</a><br/>';
						html += '<a onclick="recharge_point('+ data["data"][i]["uid"]+','+ data["data"][i]["point"] +')">积分调整</a>&nbsp;&nbsp;';
						html += '<a onclick="recharge_balance('+ data["data"][i]["uid"]+','+data["data"][i]["balance"]+')">余额调整</a><br/>';
						
						if(data["data"][i]["is_system"] != 1){
							if(data["data"][i]["user_status"] == 0){
								html += '<a onclick="unlockuser('+ data["data"][i]["uid"]+')">设置解锁&nbsp;&nbsp;&nbsp;</a>';
							}else{
								html += '<a onclick="lockuser('+ data["data"][i]["uid"]+')">设置锁定&nbsp;&nbsp;&nbsp;</a>';
							}
							html += '<a onclick="modify_password('+ data["data"][i]["uid"]+')">重置密码</a><br/>';
							
							html += '<a onclick="modify_user('+ data["data"][i]["uid"]+')">修改</a>&nbsp;&nbsp;<a onclick="delete_user('+ data["data"][i]["uid"]+')">删除</a><br/>';
							
						}
						html += '</td>'
						html += '</tr>';
					}
					
				} else {
					html += '<tr align="center"><th colspan="9">暂无符合条件的数据记录</th></tr>';
				}
				$("#list").html(html);
 					var totalpage = $("#page_count").val();
				if (totalpage == 1) {
					changeClass("all");
				}
				var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
				$("#pageNumber").append($html);
				
			}
		});
	}
//添加会员弹出
function add_user(){
	$("#add_user").modal("show");
}
//添加会员
function addUser(){
	var username = $("#username").val();
	var nickname = $("#nickname").val();
	var password = $("#password").val();
	var level_name = $("#member_level").val();
	var tel = $("#telephone").val();
	var email = $("#member_email").val();
	var sex = $("input[name='sex']:checked").val();
	var status = $("input[name='status']:checked").val();
	
	if (username == '') {
		showMessage('error','用户名不能为空');
		return;
	}
	
	if(!checkUserName(username)){
		showMessage('error','用户名已存在');
		return;
	}
	//检测输入的会员用户名是否已经存在
	$("#username").blur(function(){
		var username = $(this).val();
		$(this).css("border","1px solid #ccc");
		$("#usernameyz").css("color","black").text("");
		$("#isset_username").attr("value","不存在");
		if(username === $("#modify_username_hidden").val()){
 			return;
 		}
		checkUserName(username);
	});
	function checkUserName(username){
		var flag = true;
		$.ajax({
			type: "GET",
			url: "PLATFORM_MAIN/member/check_username",
			async : false,
			data: {"username":username},
			success: function(data){
				if(data){
					flag = false;
					$("#username").css("border","1px solid red");
					$("#usernameyz").css("color","red").text("用户名已存在");
					$("#isset_username").attr("value","存在");
				}
			} 
		});
		return flag;
	}
	if (password == null || password.length < 6) {
		showMessage('error','密码必须不小于6位！');
		return;
	}
	if(tel.length > 0){
		if(!(/^1(3|4|5|7|8)\d{9}$/.test(tel))){ 
			showMessage('error',"手机号码有误，请重填");
			return; 
		}
	}
	if(email.length > 0){
		if(!(/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(email))){ 
			showMessage('error','邮箱错误,请重填');
			return; 
		}
	}
	$.ajax({
		type : "post",
		url : "{:__URL('PLATFORM_MAIN/member/addmember')}",
		data : {
			'username' : username,
			'nickname' :nickname,
			'password' : password,
			'level_name' : level_name,
			'tel' : tel,
			'email' : email,
			'sex' : sex,
			'status' : status
		},
		success : function(data) {
			if (data['code'] > 0) {
				showMessage('success',data['message'],"{:__URL('PLATFORM_MAIN/member/memberlist')}");
				$("#add_user").modal("hide");
// 				LoadingInfo(getCurrentIndex(1,'#productTbody'));
			} else {
				showMessage('error',data['message']);
				flag = false;
			}
		}
	});
		
}
	//全选
	function CheckAll(event){
		var checked = event.checked;
		$(".style0list tbody input[type = 'checkbox']").prop("checked",checked);
	}
	//充值购物币弹出
	function showRechargeCoin(uid){
	$("#uid").val(uid);
	$("#rechargeCoin").modal('show');
	}
	//充值购物币提交
	function addRechargeCoin(){
		var uid = $("#uid").val();
		var num =$("#num").val();
		var text = $("#text").val();
		if(isNaN(num)){
			showMessage('error', '输入的购物币必须是整数！');
			return;
		}
		//alert(uid);
		$.ajax({
			type:"post",
			url:"{:__URL('PLATFORM_MAIN/Member/addRechargeCoin')}",
			data:{
				'id' : uid,
				'num' : num,
				'text' : text
			},
			async:true,
			success:function (data) {
				//alert(JSON.stringify(data));
				if (data["code"] > 0) {
					showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/Member/memberList')}");
					$("#rechargeCoin").modal('hide');
				}else{
					showMessage('error', data["message"]);
				}	
			}
		});
	}
	//积分充值
	function recharge_point(uid,point){
		$("#recharge_point").modal("show");
		$("#point_id").val(uid);
		$("#current_point").text(point);
	}
	//余额充值
	function recharge_balance(uid,balance){
		$("#recharge_balance").modal("show");
		$("#balance_id").val(uid);
		$("#current_balance").text(balance);
	}
	//充值
	function addAccount(type){
		if(type == 1){
			var id = $("#point_id").val();
			var num = $("#point").val();
			var current_point = $("#current_point").text();
			var point = (parseInt(current_point) + parseInt(num));
			if(num == ''){
				showMessage('error','积分不能为空');
				return false;
			}
			var text = $("#remark_point").val();
			if(parseInt(point) < 0){
				showMessage('error','积分不能为负数');
				return false;
			}
		}else{
			var id = $("#balance_id").val();
			var num = $("#balance").val();
			var current_balance = $("#current_balance").text();
			var balance = (parseInt(current_balance) + parseInt(num));
			if(num == ''){
				showMessage('error','余额不能为空');
				return false;
			}
			var text = $("#remark_balance").val();
			if(parseInt(balance) < 0){
				showMessage('error','余额不能为负数');
				return false;
			}
		}
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/member/addmemberaccount')}",
			data : {
				"id" : id,
				"type" : type,
				"num" : num,
				"text" : text
			},
			success : function(data) {
				if (data["code"] > 0) {
					//LoadingInfo(getCurrentIndex(id,'#productTbody'));
					showMessage('success',data['message'],"{:__URL('PLATFORM_MAIN/member/memberlist')}");
				}else{
					showMessage('error',data['message']);
				}
			}
		});
	}
	//修改会员弹出
	function modify_user(uid){
		var id = parseInt(uid);
		$("#modify_user").modal("show");
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/member/getmemberdetail')}",
			data : { 'uid':id, },
			success : function(data) {
				$("#modify_uid").val(data.uid);
				$("#modify_username").text(data.user_name);
				$("#modify_nickname").val(data.nick_name);
				//$("#modify_password").val(data.user_password);
				$("#modify_username_hidden").val(data.user_name);
				$("#modify_telephone").val(data.user_tel);
				$("#modify_member_email").val(data.user_email);
				$("#modify_member_level").find("option[value="+data.member.member_level+"]").attr("selected",true);
				$("#sex").find("input[value="+data.sex+"]").attr("checked",true);
				$("#status").find("input[value="+data.user_status+"]").attr("checked",true);
			}
		});
	}
	/**
	重置密码弹出
	*/
	function modify_password(uid){
		$("#modify_password").modal("show");
		$("#modify_userid").val(uid);
	}
	/**
	修改密码提交
	*/
	function modifypassword(){
		var uid = $("#modify_userid").val();
		var password = $("#modify_passwords").val(); 
		if (password == null || password.length < 6) {
			showTip('密码必须不小于6位！','warning');
			return false;
		}
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/member/updatememberpassword')}",
			data : {
				'uid':uid,
				'user_password' :password
			},
			success : function(data) {
				if (data['code'] > 0) {
					showMessage('success','修改成功',"{:__URL('PLATFORM_MAIN/member/memberlist')}");
					//LoadingInfo(getCurrentIndex(uid,'#productTbody'));
				} else {
					showMessage('error','修改失败');
					flag = false;
				}
			}
		});
	}
	
	
	function delete_user(uid){
		$( "#dialog" ).dialog({
			buttons: {
				"确定": function() {
					$.ajax({
						type : "post",
						url : "{:__URL('PLATFORM_MAIN/member/deletemember')}",
						data : { "uid" : uid.toString() },
						dataType : "json",
						success : function(data) {
							if(data["code"] > 0 ){
								//LoadingInfo(getCurrentIndex(uid.toString(),'#productTbody'));
								showMessage('success',data["message"],"{:__URL('PLATFORM_MAIN/member/memberlist')}");
								$("#chek_all").prop("checked", false);
							}else{
								showMessage(data["message"],'error');
							}
						}
					});
					$(this).dialog('close');
				},
				"取消,#e57373": function() {
					$(this).dialog('close');
				},
			},
			contentText:"删除会员同时会删除会员相关账户信息，确定要删除吗？",
		});
	}
// 	//修改会员
	function modifyUser(){
		var uid = $("#modify_uid").val();
		var username = $("#modify_username").text();
		var nickname = $("#modify_nickname").val();
		var tel = $("#modify_telephone").val();
		var email = $("#modify_member_email").val();
		var level_name = $("#modify_member_level").val();
		var sex = $("input[name='sex']:checked").val();
		var status = $("input[name='status']:checked").val();
			
		 if(tel.length > 0){
			if(!(/^1(3|4|5|7|8)\d{9}$/.test(tel))){ 
				showMessage('error',"手机号码有误，请重填");
				return false; 
			}
		}
		 if(email.length > 0){
			if(!(/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/.test(email))){ 
				showMessage('error','邮箱错误,请重填');
				return false; 
			}
		}
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/member/updatemember')}",
			data : {
				'uid':uid,
				'user_name' :username,
				'nick_name' : nickname,
				'level_name' : level_name,
				'tel' : tel,
				'email' : email,
				'sex' : sex,
				'status' : status
			},
			success : function(data) {
				if (data['code'] > 0) {
					showMessage('success',data['message'], "{:__URL('PLATFORM_MAIN/member/memberlist')}");
					LoadingInfo(getCurrentIndex(uid,'#productTbody'));
					$("#modify_user").hide();
				} else {
					showMessage('error',data['message']);
					flag = false;
				}
			}
		});
	}
	//批量删除
	function batchDelete() {
		var uid= new Array();
		$("#productTbody input[type='checkbox']:checked").each(function() {
			if (!isNaN($(this).val())) {
				uid.push($(this).val());
			}
		});
		if(uid.length ==0){
			$( "#dialog" ).dialog({
				buttons: {
					"确定,#e57373": function() {
						$(this).dialog('close');
					}
				},
				contentText:"请选择需要操作的记录",
				title:"消息提醒",
			});
			return false;
		}
		delete_user(uid);
	}
	
	//锁定会员
	function lockuser(uid)
	{
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/Member/memberLock')}",
			async : true,
			data : {
				"id" : uid
			},
			success : function(data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/Member/memberList')}");
				}else{
					showMessage('error', data["message"]);
				}
			}
		});
	}
	//解锁会员
	function unlockuser(uid)
	{
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/Member/memberUnlock')}",
			async : true,
			data : {
				"id" : uid
			},
			success : function(data) {
				if (data["code"] > 0) {
					showMessage('success', data["message"],"{:__URL('PLATFORM_MAIN/Member/memberList')}");
				}else{
					showMessage('error', data["message"]);
				}
			}
		});
	}
	$("#search_text").keypress(function(e){
		if(e.keyCode == 13){
			LoadingInfo(1);
		}
	});
</script>
{/block}
